package ioc05;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.Map;

/**
 * Author:shixiaojun@itany.com
 * Date:2022/3/4 15:00
 * Version:1.0-SNAPSHOT
 */
public class Test {

    public static void main(String[] args) {
//        SomeService someService = (SomeService) ObjectFactory.getObject();
//        ObjectFactory factory = new ObjectFactory();
//        SomeService someService = (SomeService) factory.getObject();

        ApplicationContext ac = new ClassPathXmlApplicationContext("ioc05/spring.xml");
        SomeService someService = (SomeService) ac.getBean("someService");

        someService.doSome();
        someService.doOther();

        // 请将下面的过程交给Spring管理
//        Map map = System.getenv();
        Map map = (Map) ac.getBean("map");
        System.out.println(map);
//        String javaHome = System.getenv("JAVA_HOME");
        String javaHome = (String) ac.getBean("javaHome");
        System.out.println(javaHome);
//        String mvnHome = System.getenv("M2_HOME");
        String mvnHome = (String) ac.getBean("mvnHome");
        System.out.println(mvnHome);

    }

}
